var appPath = getAppPath();	
var myDomain = 'http://7xogoq.com1.z0.glb.clouddn.com';
var validFile = false;
var uploader = null;
var jsonData = null;

$(function(){
	initJspGrid();
	
	// 初始化 视频播放 点击红叉  停止播放
	$('#playVideoDlg').window({
	       onBeforeClose:function(){ 
	    	   var myVideo = document.getElementsByTagName('video')[0];
	    	   myVideo.pause(); // 暂停视频 播放
	       }
	});
});

// 自定义动画列表初始化
function initJspGrid(){
	$('#designUdocGrid').datagrid({
	    url:appPath + "/yjxCust/getVipDesignUserDoc.action",
	    height:'full',
	    striped:true,
	    fitColumns:true,
	    queryParams: getQueryParam(),
	    singleSelect:true,
		checkbox:false,
	    columns:[[
	        {field:'doc_id',title:'作品ID',width:40,align:'center',sortable:false}, 
	        {field:'doc_name',title:'作品名称',width:70,align:'center',sortable:true},
	        {field:'design_id',title:'设计模板ID',width:40,align:'center',sortable:true},
	        {field:'user_id',title:'用户ID',width:40,align:'center',sortable:true},
	        {field:'showData',title:'查看VIP用户作品',width:50,align:'center',sortable:true,
	        	formatter:function(value,rowData,rowIndex){ 	// c.tmpl_json, c.tmpl_set
	        		return '<a href="javascript:void(0)" onclick="editUserDoc('+rowData.doc_id+')">查看</a>';
	        	}
	        },
	        {field:'create_time',title:'创建时间',width:80,align:'center',sortable:true},
	        {field:'update_time',title:'修改时间',width:80,align:'center',sortable:true}
	    ]],
	    pagination:true,
		rownumbers:true
	});
}

function editUserDoc(id){
	$.messager.confirm('确定','是否查看VIP用户作品？',function(r){
		if(r) {
			var editorUrl = getHomeServer()+"/encrypt/encrypt"+
			urlWithPara(
				{'isDesign':'0',// 字符类型
					'docId':id,
					'typeL':4,
					'isVip':'0',// 字符类型
					'destination':'/web_v6_0_goods/webV6_0/edit.html'
				});
			window.open(editorUrl);
		}
	});
}

function getQueryParam(){
	var queryObject = {};
	var findVip = $("#queryVipUserDoc").combobox('getValue');
	if (Number(findVip)>0) queryObject.findVip = findVip;
	return queryObject;
}

/*  查询数据
 */
function doQuery(){
	$("#designUdocGrid").datagrid('unselectAll');
	$("#designUdocGrid").datagrid('load',getQueryParam());
}

function fmtCreateTime(value, rowData, rowIndex){
	if(!value)return "";
	var s = new Date(value);
	return rowData.create_time=$.DateUtil.format(s,'yyyy/MM/dd hh:mm:ss');
}
